<template>
  <div v-if="Object.keys(detailInfo).length !== 0" class="goods-info">
    <div class="info-desc clear-fix">
      <div class="start"></div>
      <div class="desc">{{detailInfo.desc}}</div>
      <div class="end"></div>
    </div>
    <div class="info-key">{{detailInfo.detailImage[0].key}}</div>
    <div class="info-list">
      <img  v-for="(item,index) in detailInfo.detailImage[0].list" :key="index"  
      :src="item" @load="imgLoad" alt="">
    </div>
  </div>
</template>

<script>
export default {
  name:"DetailGoodsInfo",
  props:{
    detailInfo:{
      type:Object,
    }
  },
  data() {
    return {
      counter: 0,
      imagesLength: 0
      }
    },
  methods:{
    imgLoad(){
      // 判断所有的图片都加载完了，进行一次回调就可以了
      if(++this.counter === this.imagesLength){
        this.$emit('imageLoad')        
      }
    }
  },
    watch:{
      detailInfo(){
        //获取图片个数
        this.imagesLength = this.detailInfo.detailImage[0].list.length
      }
    }
  }

</script>

<style scoped>
.goods-info {
  padding: 20px 0;
  border-bottom: 5px solid #e5e5e5;
}
.info-desc {
  padding: 15px;
}
.start{
  width: 30%;
  height: 1px;
  background-color: #666;
  position: relative;
}
.start::before{
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  bottom: 0;
  background: #333;  
}
.content{
  padding: 15px 5px;
  font-size: 14px;
  color: #333;
}
.end{
  width: 30%;
  height: 1px;
  background-color: #666;
  position: relative;
  float: right;
}
.end::after{  
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  right: 0;
  bottom: 0;
  background: #333;  
}
.info-key {
  padding: 15px;
  font-size: 16px;
  color: #333;
}
.info-list {
  list-style: none;
}
.info-list img {
  width: 100%;
}
</style>